The models are quite different and cannot interact in the same
program; an sproc program cannot create pthreads and vice-versa.
Thread safe interfaces may be accessed by multiple threads or
processes simultaneously and are guaranteed to behave correctly.
In the sproc model no locking or single threading is done until the
program makes the first call to _s_p_r_o_c(). The _u_s_c_o_n_f_i_g(3P) interface
can be used to alter the thread safe behavior of these routines.
Sproc programs wishing to do parallel processing should define the
feature test macros ____SSSSGGGGIIII____MMMMPPPP____SSSSOOOOUUUURRRRCCCCEEEE and ____SSSSGGGGIIII____RRRREEEEEEEENNNNTTTTRRRRAAAANNNNTTTT____FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNNSSSS.
____SSSSGGGGIIII____MMMMPPPP____SSSSOOOOUUUURRRRCCCCEEEE changes the _e_r_r_n_o variable from a global to a per
thread private variable. It also makes certain macros and function
prototypes visible.
Pthread programs should enable the thread safe options including
reentrant functions and per thread _e_r_r_n_o by setting the POSIX
feature test macro, ____PPPPOOOOSSSSIIIIXXXX____CCCC____SSSSOOOOUUUURRRRCCCCEEEE to the value _1_9_9_5_0_6_L or greater;
the file <_p_t_h_r_e_a_d._h> enables these options automatically.
The following calls have been single threaded so that multiple
shared processes accessing them simultaneously will function
____SSSSGGGGIIII____RRRREEEEEEEENNNNTTTTRRRRAAAANNNNTTTT____FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNNSSSS enables prototypes and definitions for
reentrant versions of functions that are not thread safe by
definition (usually due to returning pointers to static data).
These alternatives are named _f_u_n_c_r and are described on the same
manual page as the original, unsafe version.
Functions that return pointers to static data are not reentrant.
When there is no alternative interface threads must provide their
own synchronization. The following functions have non-obvious
side-effects with respect to reentrancy. _ssss_eeee_tttt_llll_oooo_cccc_aaaa_llll_eeee modifies many
tables and static data. In particular, any strings returned by
_ssss_tttt_rrrr_eeee_rrrr_rrrr_oooo_rrrr and _gggg_eeee_tttt_tttt_xxxx_tttt will no longer be valid. _ssss_eeee_tttt_llll_oooo_cccc_aaaa_llll_eeee also can
affect other tables such as character class, collating sequence and
numeric separator, which many routines access. To be safe, no
thread should be using any standard C library service when a change
As described in the discussion of Section 3B above,
cc -D_BSD_COMPAT -o prog prog.c -lbsd
selects maximum compatibility with BSD. The ----llllbbbbssssdddd directive specifies
that lllliiiibbbbbbbbssssdddd....aaaa be searched before lllliiiibbbbcccc....aaaa, which selects the BSD versions
of functions that reside in both libraries (duplicated because of
identical names yet differing semantics or arguments). The routines that
fall into this category are listed in the (3B) section above. The BSD
versions may also be selected on a case-by-case basis by prefixing the
function name with BBBBSSSSDDDD when calling it in the program (e.g. _B_S_D_s_e_t_p_g_r_p).
Specifying ----DDDD____BBBBSSSSDDDD____CCCCOOOOMMMMPPPPAAAATTTT or ----DDDD____BBBBSSSSDDDD____SSSSIIIIGGGGNNNNAAAALLLLSSSS on the compile line links with
the BSD versions of the signal routines (_k_i_l_l, _k_i_l_l_p_g, _s_i_g_b_l_o_c_k, _s_i_g_n_a_l,
_s_i_g_p_a_u_s_e, _s_i_g_s_e_t_m_a_s_k, and _s_i_g_v_e_c). The program must include <_s_i_g_n_a_l._h>
or <_s_y_s/_s_i_g_n_a_l._h>. Note that a "#define _BSD_COMPAT" or "#define
_BSD_SIGNALS" placed in the source program before the inclusion of the
signal header file has the same effect as specifying the corresponding ----DDDD
compile option.
Specifying ----DDDD____BBBBSSSSDDDD____CCCCOOOOMMMMPPPPAAAATTTT or ----DDDD____BBBBSSSSDDDD____TTTTIIIIMMMMEEEE on the compile line links with
the BSD versions of the _g_e_t_t_i_m_e_o_f_d_a_y and _g_e_t_t_i_m_e_o_f_d_a_y routines. The
program must include <_s_y_s/_t_i_m_e._h>. The "#define _BSD_COMPAT" or "#define
_BSD_TIME" must be placed in the source program before the inclusion the
time header file if the ----DDDD compile option is not specified.
Defining ____BBBBSSSSDDDD____CCCCOOOOMMMMPPPPAAAATTTT gives the following additional BSD compatibility
features over and above that given by ____BBBBSSSSDDDD____SSSSIIIIGGGGNNNNAAAALLLLSSSSand ____BBBBSSSSDDDD____TTTTIIIIMMMMEEEE: you get
the BSD version of _s_e_t_j_m_p(3) and including <_s_y_s/_t_y_p_e_s._h> will cause
several additional macros and typedefs to be defined (e.g. _m_a_j_o_r, _m_i_n_o_r,
_m_a_k_e_d_e_v for dealing with device numbers). ____BBBBSSSSDDDD____CCCCOOOOMMMMPPPPAAAATTTT may affect more
things in future releases.
The System V and BSD versions of the directory routines (_o_p_e_n_d_i_r,
_s_e_e_k_d_i_r, etc.) differ greatly; inclusion of <_d_i_r_e_n_t._h> at the top of the
your program selects the System V routines, <_s_y_s/_d_i_r._h> selects the BSD
set. See also _d_i_r_e_c_t_o_r_y(3C) and _d_i_r_e_c_t_o_r_y__b_s_d(3B).